(function(global){
	
	if(!global.parent) {
		console.error("Init HteOS Adapter Error occurred : Current window has no parent");	
		return ;
	};
	var parent = global.parent;
	if(!parent.HteOS){
		console.error("Init HteOS Adapter Error occurred : Parent window has no attribute of HteOS");	
		return ;
	}
	var HteOS = parent.HteOS;
	
	/**
	 * HteApp，该类用于集成其他页面时与HteOS进行交互
	 */
	var HteApp = global.HteApp = {
		HteOS : HteOS,
		attrs : {}
	};
	
	HteApp.setTaskId = function(taskId){
		this.taskId = taskId;
		if(this.onTaskIdSet){
			this.onTaskIdSet();
		}
	}
	
	HteApp.close = function(){
		HteOS.TaskManager.stop(global.$HteTaskId);
	}
	
	HteApp.alert = function(){
		HteOS.Messager.alert.call(arguments);
	}
	
	HteApp.setBlockOnRefresh = function(blockOnRefresh,blockText){
		if(blockOnRefresh === true){
			this.blockOnRefresh = true;
			this.blockText = blockText || '确定要重新加载?';
		}else{
			this.blockOnRefresh = false;
		}
	}
	
	HteApp.confirm = function(){
		HteOS.Messager.alert.call(arguments);
	}
	
	HteApp.prompt = function(){
		HteOS.Messager.prompt.call(arguments);
	}
	
	HteApp.setPrevent = function(prevent){
		var task = HteOS.TaskManager.getTask(this.taskId);
		task.prevent = prevent;
	}
	
	HteApp.setExtra = function(property,value){
		this.attrs[property] = value;
	}
	
	HteApp.start = function(task){
		HteOS.TaskManager.start(task);
	}
	
})(window);
